package com.github.jspxnet.worktask.core.job;

import com.github.jspxnet.txweb.AssertException;
import com.github.jspxnet.txweb.util.MemberUtil;
import com.github.jspxnet.worktask.model.enums.FlowNodeEnumType;
import com.github.jspxnet.worktask.model.enums.WorkTaskEnumType;
import com.github.jspxnet.worktask.table.ConfFlowNode;

import java.util.List;

/**
 * 签收节点
 */
public class SignJobTask extends BaseTaskAction {


    @Override
    public boolean execute() throws Exception {
        AssertException.isEmpty(workTaskParam.getUserId(),"用户ID不能为空");
        if (workTaskParam.getUserId().equals(MemberUtil.getUserId(currentWorkTask.getUsers())))
        {
            currentWorkTask.setUsers(workTaskParam.getUsers());
            currentWorkTask.setWorkTaskType(WorkTaskEnumType.SIGNED.getValue());
            currentWorkTask.setFlowNodeType(FlowNodeEnumType.END.getValue());
            runtimeServiceDAO.update(currentWorkTask,new String[]{"flowNodeType","workTaskType","users"});
        }
        return true;
    }
}